//
//  SeachViewTableCell.m
//  CwinCar
//
//  Created by dlios on 15/10/28.
//  Copyright © 2015年 dlios. All rights reserved.
//

#import "SeachViewTableCell.h"

@implementation SeachViewTableCell

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if ([super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        self.imgView = [[UIImageView alloc]initWithFrame:CGRectMake(10 * suitableScreen_Width, 10 * suitableScreen_Height, 90 * suitableScreen_Width, 60 * suitableScreen_Height)];
        [self.contentView addSubview:self.imgView];

        self.titleLable = [[UILabel alloc]initWithFrame:CGRectZero];
        [self.titleLable setNumberOfLines:0];
        [self.contentView addSubview:self.titleLable];
        self.titleLable.font = [UIFont systemFontOfSize:15];
        self.timeLable = [[UILabel alloc]initWithFrame:CGRectZero];
       
        [self.contentView addSubview:self.timeLable];
        self.playCount = [[UILabel alloc]initWithFrame:CGRectZero];
        
        [self.contentView addSubview:self.playCount];
        
    }
    return self;
}
- (void)setDate:(SeachModel *)model seach:(NSString *)seach
{

    self.titleLable.frame = CGRectMake(120 * suitableScreen_Width, 10 * suitableScreen_Height, 255 * suitableScreen_Width, model.titleheight);
     self.timeLable.frame = CGRectMake(120 * suitableScreen_Width, 20 *suitableScreen_Height + model.titleheight, 100 * suitableScreen_Width, 15 * suitableScreen_Height);
    self.playCount.frame =  CGRectMake(230 * suitableScreen_Width, 20 *suitableScreen_Height + model.titleheight, 60 *suitableScreen_Width, 15 * suitableScreen_Height);
    [self.imgView sd_setImageWithURL:[NSURL URLWithString:model.smallimg] placeholderImage:[UIImage imageNamed:@"zhanweitu"]];
    NSMutableAttributedString *arrtiString = [[NSMutableAttributedString alloc]initWithString:model.title];
    NSRange range = [model.title rangeOfString:seach];
    [arrtiString addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:range];
    self.titleLable.attributedText = arrtiString;
    self.timeLable.text=  model.time;
    self.playCount.text = [NSString stringWithFormat:@"%@",model.playcount];
}
@end
